﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MBWebService.Core.Enums;
using System.Runtime.Serialization;

namespace MBWebService.Core.Classes
{
    [DataContract]
    public class NowPlayingItem : BasicItem
    {
        public NowPlayingItem()
        {
            Id = Guid.Empty;
            base.Type = MediaTypes.Unkown;
        }

        public TimeSpan ElapsedTime { get; set; }

        [DataMember]
        public string Title { get; set; }

        [DataMember]
        public string Elapsed
        {
            get
            {
                return ElapsedTime.ToStringHHmmss();
            }
            set
            {
                ElapsedTime = TimeSpan.Parse(value);
            }
        }

        [DataMember]
        public string TotalTime
        {
            get
            {
                string retVal = null;

                if (Total.HasValue)
                {
                    retVal = Total.Value.ToStringHHmmss();
                }

                return retVal;
            }
            set
            {
                Total = TimeSpan.Parse(value);
            }
        }

        [DataMember]
        public PlayState State { get; private set; }

        public TimeSpan? Total { get; set; }

        //public Microsoft.MediaCenter.PlayState PlayState
        //{
        //    set
        //    {
        //        State = value.ToString().ToEnum<PlayState>();
        //    }
        //}

        public int PlayState
        {
            set
            {
                State = (PlayState)value;
            }
        }
    }
}
